import os
from openai import OpenAI
from langchain_openai import ChatOpenAI
from pymilvus import connections

#embedding
def get_embeddings(input_text):
    client = OpenAI(
        api_key=os.getenv("OPENAI_API_KEY"),
        base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
    )
    completion = client.embeddings.create(
        model="text-embedding-v3",
        input=input_text,
        encoding_format="float"
    )
    return completion.data[0].embedding

os.environ["OPENAI_API_KEY"] = "sk-38b1a77d899b4e708287a296ceeb02e3"
connections.connect("default", host="localhost", port="19530")

#llm
llm = ChatOpenAI(
    api_key="sk-38b1a77d899b4e708287a296ceeb02e3",
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
    model="qwen-plus"
)
